package com.artqiyi.dollmachine.presenter;

import com.artqiyi.dollmachine.common.constant.ServerConstant;
import com.artqiyi.dollmachine.presenter.base.BasePresenter;
import com.artqiyi.dollmachine.presenter.base.PresenterCallbackCollection;
import com.artqiyi.dollmachine.utils.Callback.MyStringCallback;
import com.artqiyi.dollmachine.utils.JSONUtils;
import com.artqiyi.dollmachine.utils.manager.HttpManager;
import com.artqiyi.dollmachine.utils.respone.GameRecordsListRespone;
import com.artqiyi.dollmachine.utils.respone.MineCatchRecordRespone;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

/**
 * author: PengCheng
 * time: 2017/12/8 0008
 * desc:
 */

public class MineCatchRecordPresenter extends BasePresenter {

    public void getMineCatchRecord(int pageNum) {
        Map<String, String> params = new HashMap<>();
        params.put("page", String.valueOf(pageNum));
        params.put("per_page", "20");
        HttpManager.getHttpRequest(ServerConstant.getGameRecords(), params, new MyStringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                ((PresenterCallbackCollection.MineCatchRecordActivity) mCallback).onGetMineCatchRecordFail(e.getMessage());
            }

            @Override
            public void onResponse(String response, int id) {
                MineCatchRecordRespone mineCatchRecordRespone = JSONUtils.jsonString2Bean(response, MineCatchRecordRespone.class);
                ((PresenterCallbackCollection.MineCatchRecordActivity) mCallback).onGetMineCatchRecordSuccess(mineCatchRecordRespone.getData());
            }
        });
    }
}
